import request from "@/axios/request.js";

//========================分类标签操作==============================
export function getUserInfoListAPI(data) {
  return request.get(
    `/judge-backend/manage/user?pageNum=${data.pageNum}&pageSize=${data.pageSize}&authLevel=${data.authLevel}&name=${data.name}`
  );
}

export function delUserByIdsAPI(ids) {
  return request.delete(`/judge-backend/manage/user`, {
    data: ids,
  });
}

export function generateUserAPI(data) {
  return request.post(
    `/judge-backend/manage/user/create?prefix=${data.prefix}&suffix=${data.suffix}&start=${data.start}&end=${data.end}`
  );
}

export function updateUserInfoAPI(data) {
  return request.put(`/judge-backend/manage/user`, data);
}

export function updateAuthAPI(data) {
  // return request.put(
  //   `/judge-backend/manage/user/auth?uid=${data.uid}&authLevel=${data.authLevel}`
  // );
  return request({
    url: "/judge-backend/manage/user/auth",
    method: "PUT",
    params: {
      uid: data.uid,
    },
    data: [data.authLevel],
  });
}

export function updateStatusAPI(data) {
  return request.put(
    `/judge-backend/manage/user/status?uid=${data.uid}&status=${data.status}`
  );
}

export function getTemplateAPI() {
  return request.post(`/judge-backend/manage/user/export/example`, null, {
    responseType: "blob",
  });
}

export function saveUsersAPI(users) {
  return request.post(`/judge-backend/manage/user/import`, users);
}
//========================训练操作==============================
export function getTrainUserTempAPI() {
  return request.post(`/judge-backend/manage/training/export/example`, null, {
    responseType: "blob",
  });
}

export function getTrainingListAdminAPI(data) {
  return request.get(
    `/judge-backend/manage/training/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}&title=${data.title}&auth=${data.auth}`
  );
}

export function deleteTrainingAPI(ids) {
  return request.delete(`/judge-backend/manage/training`, {
    data: ids,
  });
}

export function updateTrainingAPI(data) {
  return request.put(`/judge-backend/manage/training`, data);
}

export function getTrainingDetailAPI(id) {
  return request.get(`/judge-backend/manage/training/getById?tid=${id}`);
}

export function updateTrainingStatusAPI(tid, status) {
  return request.put(
    `/judge-backend/manage/training/status?tid=${tid}&status=${status}`
  );
}

export function saveTrainingAPI(data) {
  return request.post(`/judge-backend/manage/training`, data);
}

export function getTrainingProblemListAPI(data) {
  return request.get(
    `/judge-backend/manage/trainingProblem/getTrainingProblem?tid=${data.tid}&title=${data.title}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`
  );
}

export function updateTrainingProblemAPI(data) {
  return request.put(`/judge-backend/manage/trainingProblem`, data);
}

export function getTrainingProbListAPI(data) {
  return request.get(
    `/judge-backend/manage/trainingProblem/getWantAddProblem?tid=${data.tid}&title=${data.title}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`
  );
}

export function appendTrainingProblemAPI(data) {
  return request.post(`/judge-backend/manage/trainingProblem`, data);
}

export function delTrainingProblemAPI(tid, pid) {
  return request.delete(
    `/judge-backend/manage/trainingProblem?tid=${tid}&pid=${pid}`
  );
}

export function appendProtectTrainingUserAPI(data) {
  return request.post(`/judge-backend/manage/trainingUser/save`, data);
}

export function getProtectUsersAPI(data) {
  return request.get(
    `/judge-backend/manage/trainingUser/page?pageNum=${data.pageNum}&pageSize=${data.pageSize}&username=${data.username}&tid=${data.tid}`
  );
}

export function delProtectUsersAPI(ids) {
  return request.delete(`/judge-backend/manage/trainingUser/delete`, {
    data: ids,
  });
}

//========================分类标签操作==============================

export function getCategoryAPI() {
  return request.get(`/judge-backend/manage/training/category`);
}

export function deleteCategoryAPI(ids) {
  return request.delete(`/judge-backend/manage/training/category`, {
    data: ids,
  });
}

export function appendCategoryAPI(data) {
  return request.post(`/judge-backend/manage/training/category`, data);
}

export function updateCategoryAPI(data) {
  return request.put(`/judge-backend/manage/training/category`, data);
}

export function getTagListAPI() {
  return request.get(`/judge-backend/tag/category`);
}

export function appendTagCategoryAPI(data) {
  return request.post(`/judge-backend/manage/tag/category`, data);
}

export function delTagCategoryAPI(ids) {
  return request.delete(`/judge-backend/manage/tag/category`, {
    data: ids,
  });
}

export function updateTagCategoryAPI(data) {
  return request.put(`/judge-backend/manage/tag/category`, data);
}

export function appendTagAPI(data) {
  return request.post(`/judge-backend/manage/tag`, data);
}

export function delTagAPI(ids) {
  return request.delete(`/judge-backend/manage/tag`, {
    data: ids,
  });
}

export function updateTagAPI(data) {
  return request.put(`/judge-backend/manage/tag`, data);
}

//========================题目操作==============================

export function getProblemListAPI(data) {
  return request.get(
    `/judge-backend/manage/problem?pageNum=${data.pageNum}&pageSize=${data.pageSize}&title=${data.title}&auth=${data.auth}`
  );
}

export function getProblemDetailAPI(tid) {
  return request.get(`/judge-backend/manage/problem/info?pid=${tid}`);
}

export function appendProblemAPI(data) {
  return request.post(`/judge-backend/manage/problem`, data);
}

export function deleteProblemAPI(ids) {
  return request.delete(`/judge-backend/manage/problem`, {
    data: ids,
  });
}

export function updateProblemAPI(data) {
  return request.put(`/judge-backend/manage/problem`, data);
}

export function updateProblemAuthAPI(data) {
  return request.put(
    `/judge-backend/manage/problem/auth?pid=${data.pid}&auth=${data.auth}`
  );
}

export function getCodeTemplateAPI(pid) {
  return request.get(`/judge-backend/manage/problem/codetemplate?pid=${pid}`);
}

export function saveCodeTemplateAPI(data) {
  return request.post(
    `/judge-backend/manage/problem/codetemplate/manage`,
    data
  );
}
export function uploadProblemImageAPI(data) {
  return request.post(`/judge-backend/manage/problem/upload/img`, data);
}
export function expireProblemAPI(data, type) {
  return request({
    url: "/judge-backend/manage/problem/export",
    method: "POST",
    data,
    params: {
      exportType: type,
    },
  });
}
export function importProblemAPI(postData, data = null) {
  return request({
    url: "/judge-backend/manage/problem/import",
    method: "POST",
    params: {
      importType: postData.importType,
      ossName: postData.ossName,
    },
    data,
  });
}
//========================通知操作==============================
export function postNoticeAPI(data) {
  return request.post(`/judge-backend/manage/message`, data);
}
export function updateNoticeAPI(data) {
  return request.put("/judge-backend/manage/message", data);
}
export function getNoticeAPI(data) {
  return request.get(
    `/judge-backend/manage/message/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}&like=${data.like}&status=${data.status}`
  );
}
export function delNoticeAPI(data) {
  return request.delete(`/judge-backend/manage/message`, { data });
}
//========================讨论操作==============================
export function getDiscussAPI(data) {
  return request.get(
    `/judge-backend/manage/discussion/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}&like=${data.like}&status=${data.status}`
  );
}
export function topDiscussAPI(data) {
  return request.put(
    `/judge-backend/manage/discussion/updateTop?id=${data.id}&isTop=${data.isTop}`
  );
}
export function disableDiscussAPI(data) {
  return request.put(`/judge-backend/manage/discussion/disable`, data);
}
export function delDiscussAPI(data) {
  return request.delete(`/judge-backend/manage/discussion`, { data });
}
export function delCommentAPI(data) {
  return request.delete(`/judge-backend/manage/comment/`, { data });
}
//========================举报操作==============================
export function getReportAPI(data) {
  return request(
    `/judge-backend/manage/report/list/?pageNum=${data.pageNum}&pageSize=${data.pageSize}&like=${data.like}&status=${data.status}`
  );
}
export function delReportAPI(data) {
  return request.delete(`/judge-backend/manage/report/`, { data });
}
export function searchReportAPI(id) {
  return request.get(`/judge-backend/manage/report/?reportId=${id}`);
}
export function updateReportTypeAPI(data) {
  return request.put(`/judge-backend/manage/report/`, data);
}
export function getCommentAPI(data) {
  return request.get(`/judge-backend/comment?commentId=${data}`);
}
//========================公告操作==============================
export function addAnnouncementAPI(data) {
  return request.post(`/judge-backend/manage/announcement`, data);
}
export function getAnnouncementAPI(data) {
  return request.get(
    `/judge-backend/manage/announcement/list?pageNum=${data.pageNum}&pageSize=${data.pageSize}&like=${data.like}&status=${data.status}`
  );
}
export function isShowAPI(data) {
  return request.put(`/judge-backend/manage/announcement/show`, data);
}
export function delAnnouncementAPI(data) {
  return request.delete(`/judge-backend/manage/announcement`, { data });
}
export function updateAnnouncementAPI(data) {
  return request.put(`/judge-backend/manage/announcement`, data);
}
//========================比赛操作==============================
export function getRaceListAPI(data) {
  return request.get(
    `/judge-contest/manage/contest?pageNum=${data.pageNum}&pageSize=${data.pageSize}&format=${data.format}&name=${data.name}`
  );
}

export function appendRaceAPI(data) {
  return request.post(`/judge-contest/manage/contest`, data);
}

export function delRaceAPI(ids) {
  return request.delete(`/judge-contest/manage/contest`, {
    data: ids,
  });
}

export function getRaceDetailAPI(id) {
  return request.get(`/judge-contest/manage/contest/${id}`);
}

export function updateRaceVisibleAPI(cid, visible) {
  return request.put(
    `/judge-contest/manage/contest/visible?cid=${cid}&visible=${visible}`
  );
}

export function updateRaceAPI(data) {
  return request.put(`/judge-contest/manage/contest`, data);
}

export function getGroupListAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/group?cid=${data.cid}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`
  );
}

export function getRaceUsersAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/user?cid=${data.cid}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`
  );
}

export function delGroupAPI(ids) {
  return request.delete(`/judge-contest/manage/contest/group`, {
    data: ids,
  });
}

export function removeFromTeamAPI(cgid, ids) {
  return request.delete(
    `/judge-contest/manage/contest/user/group?cgid=${cgid}`,
    {
      data: ids,
    }
  );
}

export function getRaceUsersNoIncludeLeaderAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/user/userinfo?name=${data.name}&pageNum=${data.pageNum}&pageSize=${data.pageSize}&cid=${data.cid}&isReg=${data.isReg}&isLeader=${data.isLeader}&major=${data.major}&majorLike=${data.majorLike}`
  );
}

export function updateRaceTeamAPI(data) {
  return request.put(`/judge-contest/manage/contest/group`, data);
}

export function appendRaceTeamAPI(data) {
  return request.post(
    `/judge-contest/manage/contest/group?cid=${data[0].cid}`,
    data
  );
}

export function appendUserIntoTeamAPI(cid, cgid, ids) {
  return request.post(
    `/judge-contest/manage/contest/user?cid=${cid}&cgid=${cgid}`,
    ids
  );
}

export function removeFromRaceAPI(cid, ids) {
  return request.delete(`/judge-contest/manage/contest/user?cid=${cid}`, {
    data: ids,
  });
}
//========================比赛题目操作==============================

export function getRaceProblemsAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/problem?cid=${data.cid}&pageNum=${data.pageNum}&pageSize=${data.pageSize}&name=${data.name}`
  );
}

export function getUnUsedProblemsAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/problem/right?cid=${data.cid}&pageNum=${data.pageNum}&pageSize=${data.pageSize}&name=${data.name}&type=${data.type}&isPublic=${data.isPublic}`
  );
}

export function appendProblemToRaceAPI(data) {
  return request.post(`/judge-contest/manage/contest/problem`, data);
}

export function updateRaceProblemAPI(data) {
  return request.put(`/judge-contest/manage/contest/problem`, data);
}

export function delRaceProblemAPI(ids) {
  return request.delete(`/judge-contest/manage/contest/problem`, {
    data: ids,
  });
}
//========================比赛公告操作==============================
export function postRaceNoticeAPI(data) {
  return request.post(`/judge-contest/manage/contest/notice`, data);
}
export function getRaceNoticeAPI(data) {
  return request.get(
    `/judge-contest/manage/contest/notice?pageNum=${data.pageNum}&pageSize=${data.pageSize}&cid=${data.cid}&like=${data.like}`
  );
}
export function updateRaceNoticeAPI(data) {
  return request.put(`/judge-contest/manage/contest/notice`, data);
}
export function delRaceNotice(data) {
  return request.delete(`/judge-contest/manage/contest/notice`, { data });
}
//========================数据视图操作==============================
export function getLoginInfoAPI() {
  return request.get(`/judge-backend/loginlog`);
}
export function getUserNumAPI() {
  return request.get(`/judge-backend/manage/user/count`);
}
export function getWeekProblemNumAPI() {
  return request.get(`/judge-backend/manage/problem/week/count`);
}
export function getWeekAcNumAPI() {
  return request.get(`/judge-backend/manage/Judge/week/count`);
}
export function getWeekRaceNumAPI() {
  return request.get(`/judge-contest/manage/contest/week/count`);
}
export function getJudgeBackendServeAPI(data) {
  return request.get(
    `/judge-backend/manage/services?pageNum=${data.pageNum}&pageSize=${data.pageSize}&serviceName=judge-backend-service`
  );
}
export function getGateWayAPI(data) {
  return request.get(
    `/judge-backend/manage/services?pageNum=${data.pageNum}&pageSize=${data.pageSize}&serviceName=gateway`
  );
}
export function getJudgeContestServiceAPI(data) {
  return request.get(
    `/judge-backend/manage/services?pageNum=${data.pageNum}&pageSize=${data.pageSize}&serviceName=judge-contest-service`
  );
}
export function getJudgeOriginServiceAPI(data) {
  return request.get(
    `/judge-backend/manage/services?pageNum=${data.pageNum}&pageSize=${data.pageSize}&serviceName=judge-origin-service`
  );
}
//========================封榜接口==============================
export function getRaceRankAdminAPI(data) {
  return request.post(
    `/judge-contest/manage/contest/rank/user?pageNum=${data.pageNum}&pageSize=${data.pageSize}&removeStar=${data.removeStar}&cid=${data.cid}&keyword=${data.keyword}`
  );
}
export function getRaceTeamRankAdminAPI(data) {
  return request.post(
    `/judge-contest/manage/contest/rank/group?pageNum=${data.pageNum}&pageSize=${data.pageSize}&removeStar=${data.removeStar}&cid=${data.cid}&keyword=${data.keyword}`
  );
}
export function cancelLockAdminAPI(cid) {
  return request.post(
    `/judge-contest/manage/contest/rank/lockOff?lock=0&cid=${cid}`
  );
}

//========================前台训练接口个人信息获取接口==============================
export function getTrainIngListAPI(data) {
  return request.get(
    `/judge-backend/manage/training/trainingRank?pageNum=${data.pageNum}&pageSize=${data.pageSize}&keyWord=${data.keyword}&tid=${data.tid}`
  );
}
//========================前台训练接口个人信息获取接口==============================
//获取所有权限
export function getAllPermissionAPI(data) {
  return request({
    url: "/judge-backend/manage/permission",
    method: "GET",
    params: {
      ...data,
    },
  });
}

//获取所有角色
export function getAllRoleAPI(data) {
  return request({
    url: "/judge-backend/manage/role",
    method: "GET",
    params: {
      ...data,
    },
  });
}
//新增角色
export function addRoleAPI(data) {
  return request({
    url: "/judge-backend/manage/role",
    method: "POST",
    data,
  });
}
//修改角色
export function updateRoleAPI(data) {
  return request({
    url: "/judge-backend/manage/role",
    method: "PUT",
    data,
  });
}
//删除角色
export function deleteRoleAPI(data) {
  return request({
    url: "/judge-backend/manage/role",
    method: "DELETE",
    data,
  });
}
